package com.dyz.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dyz.domain.WorkIssue;
import com.dyz.model.Result;
import com.dyz.service.IWorkIssueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

@RestController
@Api(tags = "工单管理")
@RequestMapping("/workIssue")
public class WorkIssueController {
    @Resource
    private IWorkIssueService workIssueService;
    @GetMapping("/getList")
    @ApiOperation(value = "获取列表")
    @PreAuthorize("hasAuthority('work_issue_query')")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页"),
            @ApiImplicitParam(name = "size", value = "每页显示条数"),
    })
    public Result<?> getWorkIssueList(@ApiIgnore Page<WorkIssue> page,String startTime,String endTime,String status) {
        return workIssueService.getWorkIssueList(page,startTime,endTime,status);
    }
    @GetMapping("/getOneObj/{id}")
    @ApiOperation(value = "单个工单信息")
    @PreAuthorize("hasAuthority('work_issue_query')")
    public Result<?> getOneObj(@PathVariable Long id) {
        return Result.success(workIssueService.getById(id));
    }
    @PostMapping("/updateAnswer")
    @ApiOperation(value = "回复工单")
    @PreAuthorize("hasAuthority('work_issue_update')")
    public Result<?> updateAnswer(@RequestBody WorkIssue workIssue) {
        return workIssueService.updateAnswer(workIssue);
    }
}
